#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>

int* twoSum(int* numbers, int numbersLen, int target, int* returnSize) {
    // write code here
    int* answer = (int*)calloc(2, sizeof(int));
    int left = 0;
    int right = numbersLen - 1;
    int remove = right;
    while (1)
    {
        if (*(numbers + left) + *(numbers + remove) == target)
        {
            break;
        }
        remove--;
        if (left >= remove)
        {
            right--;
            left++;
            remove = right;
        }
    }
    answer[0] = left + 1;
    answer[1] = remove + 1;
    *returnSize = 2;
    return answer;
}

int main()
{
    int s = 0;
    int num[] = { 3,3,4 };
    int* f = twoSum(num, 3, 6,&s);
    for (int i = 0; i < 2; i++)
    {
        printf("%d ", f[i]);
    }
    return 0;
}

